﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ml.Math;
using System.Collections;

namespace ml.Unsupervised
{
    public class Cluster<T>
    {
        internal int Id { get; set; }
        internal IEnumerable<Vector> Points { get; set; }
        public IEnumerable<T> Members { get; set; }
        public Cluster<T>[] Children { get; set; }
        //public Cluster<T> Left { get; set; }
        //public Cluster<T> Right { get; set; }

        public Cluster()
        {
        }

        public Cluster(int id, Cluster<T> left, Cluster<T> right )
        {
            Id = id;
            Children = new Cluster<T>[] { left, right };
            Points = left.Points.Concat(right.Points);

            // maybe only need item at leaves
            Members = left.Members.Concat(right.Members).ToArray();
        }

        public Cluster(int id, IEnumerable<Cluster<T>> children)
        {
            Id = id;
            Children = children.ToArray();
        }
    }
}
